Skip to content

Conversation

sayakpaul
Copy link
Member

What does this PR do?

More reductions in LoC.

@sayakpaul sayakpaul requested a review from DN6 September 23, 2025 08:04


class AutoencoderKLHunyuanVideoTests(ModelTesterMixin, UNetTesterMixin, unittest.TestCase):
class AutoencoderKLHunyuanVideoTests(ModelTesterMixin, VAETestMixin, UNetTesterMixin, unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Let's call it AutoencoderTesterMixin to be consistent. Also it looks like UNetTesterMixin is used in all the autoencoder tests? It only has a single test method. Let's add it to the AutoencoderTesterMixin and just have these classes inherit from their specific Mixin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@sayakpaul sayakpaul requested a review from DN6 September 24, 2025 03:51
@sayakpaul sayakpaul requested a review from DN6 September 24, 2025 05:14
@DN6
Copy link
Collaborator

DN6 commented Oct 8, 2025

I think we can remove the unittest dependency for these tests too?

@sayakpaul
Copy link
Member Author

Oh I think for that, we need to make test_modeling_common get rid of unittest, first.

@sayakpaul sayakpaul requested a review from dg845 October 17, 2025 02:30


class AutoencoderKLTests(ModelTesterMixin, UNetTesterMixin, unittest.TestCase):
class AsymmetricAutoencoderKLTests(ModelTesterMixin, unittest.TestCase):
Copy link
Collaborator

@dg845 dg845 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following autoencoder modules currently don't inherit from AutoencoderTesterMixin:

  • AsymmetricAutoencoderKL
  • AutoencoderKLCosmos
  • AutoencoderDC
  • AutoencoderKLTemporalDecoder
  • AutoencoderKLMagvit
  • AutoencoderKLMochi
  • AutoencoderOobleck
  • VQModel

Is this because they don't have enable_tiling or enable_slicing methods? Since test_enable_disable_tiling and test_enable_disable_slicing check for these methods, it seems like it should be safe for them to inherit from AutoencoderTesterMixin. It would also have the added benefit of allowing them to have the one test that was moved from UNetTesterMixin into AutoencoderTesterMixin.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No one has used it :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also have the added benefit of allowing them to have the one test that was moved from UNetTesterMixin into AutoencoderTesterMixin.

Do you mean test_forward_with_norm_groups?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I edited my comment above to try to consolidate all of the models that don't inherit from AutoencoderTesterMixin. Do you think it would make sense for all autoencoder test classes to inherit from AutoencoderTesterMixin, as the slicing/tiling tests will be skipped if enable_slicing/enable_tiling methods are not available?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean test_forward_with_norm_groups?

Yeah I think that's the one

@sayakpaul
Copy link
Member Author

@dg845 thanks! Nice suggestion: #12374 (comment).

I applied it accordingly. It also helped us reduce a bit more LoC. PTAL.

@sayakpaul sayakpaul requested a review from dg845 October 17, 2025 05:14
@dg845
Copy link
Collaborator

dg845 commented Oct 17, 2025

I saw that in the https://github.com/huggingface/diffusers/actions/runs/18580604097/job/52974552004?pr=12374 CI run the following tests failed:

FAILED tests/models/autoencoders/test_models_autoencoder_dc.py::AutoencoderDCTests::test_layerwise_casting_inference - RuntimeError: GET was unable to find an engine to execute this computation
FAILED tests/models/autoencoders/test_models_autoencoder_dc.py::AutoencoderDCTests::test_layerwise_casting_memory - RuntimeError: GET was unable to find an engine to execute this computation

I tried both of them locally on DGX and they passed (although my environment is not exactly synced up to the CI environment). Are these tests just flaky? It looks like the error might have to do with GPU availability.

EDIT: It looks like these same tests failed again on the next CI run with the same error: https://github.com/huggingface/diffusers/actions/runs/18583169787/job/52981958899?pr=12374.

@sayakpaul
Copy link
Member Author

Yeah those are unrelated to the PR, I think.

@sayakpaul
Copy link
Member Author

Fixed the Mochi related tests:
https://github.com/huggingface/diffusers/actions/runs/18583169808/job/52981961284?pr=12374#step:7:11793

For AutoencoderKLMagvitTests, failing, I have skipped them for now as they need deeper inspection (doesn't have to be prioritized as it's not used).

LMK what you think.

@dg845

@sayakpaul
Copy link
Member Author

Also, regarding https://github.com/huggingface/diffusers/actions/runs/18583169787/job/52981958899?pr=12374, I think those are failing because of the CI hardware (uses T4 instances having compute capability of 7.5). Taking a look. The FP8 stuff there needs some hardware compatibility to work.

Copy link
Collaborator

@dg845 dg845 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (assuming nothing weird comes up in the CI 😅)

@sayakpaul sayakpaul merged commit af76988 into main Oct 17, 2025
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants